<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
    <script src="${pageContext.request.contextPath}/statics/js/jquery-3.5.1.js"></script>
    <script>
        $(function () {
            $("#btn").click(()=>{
                // console.log("hello!");
                $.ajax({
                    url:"${pageContext.request.contextPath}/t2",
                    success:(data)=>{
                        var html = "";
                        for (let i =0;i<data.length;i++){
                            html+="<tr>"
                                + "<td>"+data[i].id+"</td>"
                                + "<td>"+data[i].name+"</td>"
                                + "<td>"+data[i].age+"<td>"
                                +"<tr>"
                        }
                        $("#content").html(html);
                    }
                })
            })
        })
    </script>
</head>
<body>
<div class="container">
    <input type="button" value="获取数据" class="btn btn-primary" id="btn">
    <table class="table table-hover">
        <thead>
        <tr>
            <td>ID</td>
            <td>姓名</td>
            <td>年龄</td>
        </tr>
        </thead>
        <tbody id="content">

        </tbody>
    </table>
</div>


</body>
</html>
